package com.itheima.insatnce02;

import java.util.Date;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

//切面类  编写通知 ——基于XML的声明式AspectJ
@Aspect
@Component
public class MyAspect {
	
	@Pointcut("execution(* com.itheima.insatnce02.*.fly(..))") //切入点表达式
	//使用一个返回值为void 方法体空的方法来命名切入点
	public void myPointCut() {
		
	}
	//前置通知
	@Before("myPointCut()")
	public void myBefore(JoinPoint joinPoint) {
		System.out.print("飞行前：检查体温中........,");
		System.out.println("对象为："+joinPoint.getTarget());
		
	}
	
	//后置通知
	@AfterReturning("myPointCut()")
	public void myAfterReturning(JoinPoint joinPoint) {
		
		System.out.println("飞行后：登记时间中.......,"+new Date());
		System.out.println();
	}
	
}
